<?php

/**
 * 后台路由
 */
Route::group(['namespace' => 'Api', 'prefix' => 'api'], function () {
    Route::post('ajax-packet', 'RedPacketController@ajaxPacket');//红包API接口

    Route::match(['post', 'get'], 'hotspot/upload', 'HotspotController@upload');//上传热点数据
});

/**后台模块**/
Route::group(['namespace' => 'Admin', 'prefix' => 'admin'], function () {

    Route::get('login', 'AdminsController@showLoginForm')->name('login');  //后台登陆页面
    Route::post('login-handle', 'AdminsController@loginHandle')->name('login-handle'); //后台登陆逻辑
    Route::get('logout', 'AdminsController@logout')->name('admin.logout'); //退出登录

    /**需要登录认证模块**/
    Route::middleware(['auth:admin', 'rbac'])->group(function () {

        Route::resource('index', 'IndexsController', ['only' => ['index']]);  //首页

        Route::get('index/main', 'IndexsController@main')->name('index.main'); //首页数据分析
        Route::get('index/game', 'IndexsController@game')->name('index.game');//游戏选择
        Route::get('index/test', 'IndexsController@test')->name('index.test');//测试方法
        Route::get('clearCache', function () {
            Artisan::call('cache:clear');
            return "缓存清理成功";
        });//清理cache

        Route::resource('admins', 'AdminsController', ['only' => ['index', 'create', 'store', 'update', 'edit']]); //管理员
        Route::get('admins/status/{statis}/{admin}', 'AdminsController@status')->name('admins.status');
        Route::get('admins/delete/{admin}', 'AdminsController@delete')->name('admins.delete');


        Route::resource('roles', 'RolesController', ['only' => ['index', 'create', 'store', 'update', 'edit', 'destroy']]);  //角色
        Route::get('roles/access/{role}', 'RolesController@access')->name('roles.access');
        Route::post('roles/group-access/{role}', 'RolesController@groupAccess')->name('roles.group-access');

        Route::resource('rules', 'RulesController', ['only' => ['index', 'create', 'store', 'update', 'edit', 'destroy']]);  //权限
        Route::get('rules/status/{status}/{rules}', 'RulesController@status')->name('rules.status');

        Route::resource('actions', 'ActionLogsController', ['only' => ['index', 'destroy']]);  //日志

        //充值与消费
        Route::namespace('PayAndConsume')->group(function () {
            Route::match(['post', 'get'], 'stat_data', 'StatController@data')->name('stat.data');

            Route::match(['post', 'get'], 'stat_retention', 'StatController@retention')->name('stat.retention');

            Route::match(['post', 'get'], 'stat_ltv', 'StatController@ltv')->name('stat.ltv');

            Route::match(['post', 'get'], 'pay_rank', 'PayController@rank')->name('pay.rank');
            Route::get('pay_detail', 'PayController@detail')->name('pay.detail');

            Route::match(['post', 'get'], 'pay_stat', 'PayController@stat')->name('pay.stat');

            Route::match(['post', 'get'], 'pay_trade', 'PayController@trade')->name('pay.trade');

            Route::match(['post', 'get'], 'pay_grade', 'PayController@grade')->name('pay.grade');

            Route::match(['post', 'get'], 'stat_sumData', 'StatController@sumData')->name('stat.sumData');

            Route::match(['post', 'get'], 'stat_server', 'StatController@server')->name('stat.server');

            Route::match(['post', 'get'], 'stat_online', 'StatController@online')->name('stat.online');

            Route::match(['post', 'get'], 'stat_liveOnline', 'StatController@liveOnline')->name('stat.liveOnline');

            Route::match(['post', 'get'], 'stat_userLevel', 'StatController@userLevel')->name('stat.userLevel');

            Route::match(['post', 'get'], 'hotspot_index', 'HotspotController@index')->name('hotspot.index');//热点数据
        });

        //GM工具
        Route::namespace('GameTool')->group(function () {
            Route::match(['post', 'get'], 'redpacket_index', 'RedPacketController@index')->name('redpacket.index');//红包管理
            Route::get('redpacket_withdraw', 'RedPacketController@withdraw')->name('redpacket.withdraw');
            Route::get('redpacket_reject', 'RedPacketController@reject')->name('redpacket.reject');

            Route::match(['post', 'get'], 'chatlog_index', 'ChatLogController@index')->name('chatlog.index');//聊天工具

            Route::match(['post', 'get'], 'mail_index', 'MailController@index')->name('mail.index');//邮件补偿
            Route::resource('mail', 'MailController', ['only' => ['create', 'store', 'update', 'edit']]);
            Route::get('mail/status/{status}/{id}', 'MailController@status')->name('mail.status');
            Route::get('mail/checkStatus/{status}/{id}', 'MailController@checkStatus')->name('mail.checkStatus');
            Route::match(['post', 'get'], 'mail_check', 'MailController@check')->name('mail.check');
            Route::get('mail_batch_create', 'MailController@batchCreate')->name('mail.batchCreate');
            Route::post('mail_batch_store', 'MailController@batchStore')->name('mail.batchStore');

            Route::match(['post', 'get'], 'recharge_index', 'RechargeController@index')->name('recharge.index');//充值补偿
            Route::resource('recharge', 'RechargeController', ['only' => ['create', 'store', 'update', 'edit']]);
            Route::get('recharge/status/{status}/{id}', 'RechargeController@status')->name('recharge.status');
            Route::get('recharge/checkStatus/{status}/{id}', 'RechargeController@checkStatus')->name('recharge.checkStatus');
            Route::match(['post', 'get'], 'recharge_check', 'RechargeController@check')->name('recharge.check');
            Route::get('recharge_batch_create', 'RechargeController@batchCreate')->name('recharge.batchCreate');
            Route::post('recharge_batch_store', 'RechargeController@batchStore')->name('recharge.batchStore');

            Route::match(['post', 'get'], 'userinfo_index', 'UserInfoController@index')->name('userinfo.index');//玩家信息
            Route::get('userinfo_detail', 'UserInfoController@detail')->name('userinfo.detail');
        });

        //配置
        Route::namespace('Config')->group(function () {
            Route::resource('games', 'GamesController', ['only' => ['index', 'create', 'store', 'update', 'edit']]); //游戏
            Route::get('games/status/{statis}/{game}', 'GamesController@status')->name('games.status');
            Route::get('games/delete/{game}', 'GamesController@delete')->name('games.delete');

            Route::match(['post', 'get'], 'channels_index', 'ChannelsController@index')->name('channels.index');//渠道
            Route::resource('channels', 'ChannelsController', ['only' => ['create', 'store', 'update', 'edit']]);
            Route::get('channels/status/{status}/{id}', 'ChannelsController@status')->name('channels.status');
            Route::get('channels/delete/{id}', 'ChannelsController@delete')->name('channels.delete');

            Route::match(['post', 'get'], 'servers_index', 'ServersController@index')->name('servers.index');//服务器
            Route::resource('servers', 'ServersController', ['only' => ['create', 'store', 'update', 'edit']]);
            Route::get('servers/status/{status}/{id}', 'ServersController@status')->name('servers.status');
            Route::get('servers/delete/{id}', 'ServersController@delete')->name('servers.delete');
        });

        //总数据
        Route::namespace('TotalData')->group(function () {
            Route::match(['post', 'get'], 'totalData_stat_sumData', 'StatController@sumData')->name('totalData.stat.sumData');
        });

        //财务
        Route::namespace('Finance')->group(function () {
            Route::match(['post', 'get'], 'finance_check_index', 'CheckController@index')->name('finance.check.index');
            Route::resource('check', 'CheckController', ['only' => ['create', 'store', 'update', 'edit']]);
        });
    });
});
